<template>
  <div class="Withdrawal_box" v-loading="loading">
    <div class="Withdrawal_box_text1">{{ $t("button.Withdrawal") }}</div>
    <div class="Withdrawal_box_text2"></div>
    <div class="Withdrawal_box_text3">
      {{ $t("button.Withdrawable") }}
      <span style="color: #00b0f0">{{ moneys }}</span
      >{{ $t("button.Points1") }}
    </div>
    <div class="Withdrawal_box_text4">
      {{ $t("button.USDT") }}
      <el-input v-model="query.ustd_address" style="width: 600px">{{
        $t("button.Networkso")
      }}</el-input>
    </div>
    <div class="Withdrawal_box_text5">
      {{ $t("button.Networkso") }}
      <el-radio
        style="padding: 0 50px 0 20px"
        v-model="query.network"
        label="TRC20"
        value="TRC20"
        size="medium"
      >
        {{ $t("button.TRC20") }}</el-radio
      >
      {{ $t("button.Gas") }}{{ moneyso + "$" }}
    </div>
    <div class="Withdrawal_box_text6">
      {{ $t("button.Amounts")
      }}<el-input
        v-model="query.money"
        :placeholder="$t('button.amount')"
      ></el-input>
    </div>
    <div class="Withdrawal_box_text6">
      {{ $t("button.Password")
      }}<el-input
        v-model="query.user_password"
        :placeholder="$t('button.EnterPassword')"
        show-password
      ></el-input>
    </div>
    <div class="Withdrawal_box_text7 cursor" @click="btnFn">
      {{ $t("button.Application") }}
    </div>
    <div class="MyPonit_box_child3">
      {{ $t("button.Withdrawals") }}
      <span style="color: skyblue">{{ totalmoney }}</span>
      {{ $t("button.Pointssss") }}
    </div>
    <div class="table_text" v-loading="loadings">
      <el-table :data="tableDataCurrent" border style="width: 100%">
        <el-table-column prop="date" :label="$t('button.Date')">
        </el-table-column>
        <el-table-column prop="money" :label="$t('button.Amount3')">
        </el-table-column>
        <el-table-column
          prop="ustd_address"
          :label="$t('button.Withdrawal3')"
          show-overflow-tooltip
        >
        </el-table-column>
        <el-table-column prop="network" :label="$t('button.Network3')">
        </el-table-column>
        <el-table-column prop="gas_money" :label="$t('button.Fees')">
        </el-table-column>
        <el-table-column prop="status" :label="$t('button.Action3')">
          <template slot-scope="scope">
            <span
              :style="{
                color:
                  scope.row.status == 0
                    ? 'skyblue'
                    : scope.row.status == 1
                    ? '#ccc'
                    : '#ffa800',
              }"
              >{{
                scope.row.status == 0
                  ? "in progress"
                  : scope.row.status == 1
                  ? "complete"
                  : "Rejected"
              }}</span
            >
          </template>
        </el-table-column>
      </el-table>
      <el-pagination
        style="text-align: center; margin: 20px 0"
        background
        v-show="tableData.total > 0"
        :total="tableData.total"
        :page.sync="listQuery.page"
        :page-size="listQuery.limit"
        :size.sync="listQuery.limit"
        @current-change="getLists"
        layout="total,prev, pager, next"
      >
      </el-pagination>
    </div>
  </div>
</template>

<script>
import { indexs } from "@/api/product.js"; //   购买
import { introduce, withdraw, withdraworder } from "@/api/omc.js"; //  介绍 提现 提现记录
export default {
  name: "Withdrawal",
  data() {
    return {
      loadings: false, // loading
      loading: false, // loadings
      moneys: "", // 提现手续费
      query: {
        user_id: "", // 账户id
        money: "", // 提现积分
        user_password: "", // 密码
        ustd_address: "", //  ustd 地址
        network: "", // TRC20
      },
      listQuery: {
        // Dang当前页
        page: 1,
        // 每页多少条
        limit: 3,
      },
      tableDataCurrent: [], // 列表数据
      tableQuery: {
        user_id: "",
        page: 1, // 当前页
      },
      tableData: {},
      totalmoney: "", // 总金额
      moneyso: "", // 提现手续费
    };
  },
  created() {
    this.tableQuery.user_id = sessionStorage.getItem("id");
    this.query.user_id = sessionStorage.getItem("id");
    this.introduce();
    this.withdraworder(this.tableQuery);
    this.indexs(this.tableQuery);
  },
  methods: {
    // 个人信息
    async indexs(query) {
      try {
        const data = await indexs(query);
        console.log(data);
        this.moneys = data.data.withdraw_money; // grade
        this.query.ustd_address = data.data.ustd_address;
      } catch (error) {
        console.log(error);
      }
    },
    getLists(val) {
      console.log(val);
      this.loadings = true;
      this.tableDataCurrent = this.tableData.data.slice(
        (val - 1) * this.listQuery.limit,
        val * this.listQuery.limit
      );
      console.log((this.listQuery.page - 1) * this.listQuery.limit);
      console.log(this.listQuery.page * this.listQuery.limit);
      this.loadings = false;
      console.log(this.tableDataCurrent);
    },
    // 提现安妮
    btnFn() {
      this.withdraw(this.query);
    },
    // 介绍详情
    async introduce(query) {
      try {
        const { data } = await introduce(query);
        this.moneyso = data.money;
        console.log(data);
      } catch (error) {
        console.log(error);
      }
    },
    // 提现记录
    async withdraworder(query) {
      try {
        const data = await withdraworder(query);
        this.tableData = data.data;
        this.totalmoney = data.data.total_money;
        console.log(data);
        this.getLists(this.listQuery.page);
        console.log(data);
      } catch (error) {
        console.log(error);
      }
    },
    // 提现
    async withdraw(query) {
      this.loading = true;
      try {
        const data = await withdraw(query);
        if (data.result_code == 200) {
          this.$message({
            type: "success",
            message: data.msg,
          });
          this.indexs(this.tableQuery);
          this.withdraworder(this.tableQuery);
        } else {
          this.$message({
            type: "error",
            message: data.msg,
          });
        }
        this.loading = false;
        console.log(data);
      } catch (error) {
        this.loading = false;
        console.log(error);
      }
    },
  },
  // 提交
  btnFn() {},
};
</script>

<style scoped>
.el-table {
  font-size: 20px;
}
::v-deep .el-table .el-table__cell {
  padding: 20px 0 !important;
}
.table_text {
  margin: 75px 142px 0;
}
::v-deep .el-pagination span:not([class*="suffix"]) {
  font-size: 22px;
  line-height: 44px;
}
::v-deep .btn-prev {
  text-align: center;
  line-height: 33px;
  width: 44px !important;
  height: 44px !important;
}
::v-deep .btn-next {
  text-align: center;
  line-height: 33px;
  width: 44px !important;
  height: 44px !important;
}
::v-deep .el-pager li {
  font-size: 20px;
  text-align: center;
  line-height: 44px;
  width: 44px !important;
  height: 44px !important;
}
::v-deep .el-input {
  margin-left: 30px;
  width: 300px;
  height: 50px;
  border: 2px solid #999999;
  border-radius: 10px;
}
::v-deep .el-input__inner {
  width: 100%;
  height: 100%;
  font-size: 20px;
}
::v-deep .el-radio__inner {
  width: 20px !important;
  height: 20px !important;
}
::v-deep .el-radio__label {
  font-size: 20px !important;
}
.MyPonit_box_child3 {
  margin: 0 0 0 152px;
  height: 28px;
  font-size: 30px;
  font-family: Arial;
  font-weight: bold;
  color: #1a1a1a;
  line-height: 110px;
}
.Withdrawal_box {
  box-sizing: border-box;
  width: 100%;
  height: 922px;
  background: #ffffff;
}
.Withdrawal_box_text1 {
  margin: 62px 0 0 132px;
  height: 42px;
  font-size: 56px;
  font-family: Arial;
  font-weight: bold;
  color: #1a1a1a;
}
.Withdrawal_box_text2 {
  margin: 53px 0 0 0;
  width: 1918px;
  height: 2px;
  background: #bfbfbf;
}
.Withdrawal_box_text3 {
  margin: 26px 0 0 132px;
  height: 23px;
  font-size: 30px;
  font-family: Arial;
  font-weight: 400;
  color: #666666;
}
.Withdrawal_box_text4 {
  margin: 26px 0 0 132px;
  box-sizing: border-box;
  height: 18px;
  font-size: 24px;
  font-family: Arial;
  font-weight: 400;
  color: #666666;
  line-height: 18px;
}
.Withdrawal_box_text4_child {
  padding-left: 22px;
  display: inline-block;
  width: 871px;
  height: 52px;
  background: #eeeeee;
  border: 1px solid #bfbfbf;
  border-radius: 6px;
  font-size: 22px;
  font-family: Arial;
  font-weight: 400;
  color: #666666;
  line-height: 52px;
}
.Withdrawal_box_text5 {
  margin: 60px 0 0 132px;
  box-sizing: border-box;
  height: 18px;
  font-size: 24px;
  font-family: Arial;
  font-weight: 400;
  color: #666666;
  line-height: 18px;
}
.Withdrawal_box_text6 {
  margin: 30px 0 0 132px;
  box-sizing: border-box;
  height: 40px;
  font-size: 24px;
  font-family: Arial;
  font-weight: 400;
  color: #666666;
  line-height: 18px;
}
.Withdrawal_box_text7 {
  margin: 27px 0 0 132px;
  width: 492px;
  height: 63px;
  background: #00b0f0;
  border-radius: 10px;
  font-size: 30px;
  font-family: Arial;
  font-weight: 400;
  text-align: center;
  color: #ffffff;
  line-height: 63px;
}
</style>